package uk.ac.manchester.cs.haphan.modbench;

/**
 *
 * @author HaPhan
 * The University of Manchester
 * phanh [at] cs.man.ac.uk
 */
import java.io.File;
import java.util.ArrayList;


public class FileHandler {

    private String root = "data";
    private String input = "input";
    private String output = "modularity";
    private String currentFolder;

    public FileHandler(String rootFolder) {
        this.root = rootFolder;
        this.initFolders();
        this.currentFolder = Helper.CurrentDate();
    }

    private void initFolders() {
        new File(new File(this.root),this.input).mkdirs();
        new File(new File(this.root),this.output).mkdirs();
    }

    public ArrayList<File> getInputFiles() {
        ArrayList<File> result = new ArrayList<File>();
        File inputFile = new File(this.root + File.separator + this.input);
        for (File onto : inputFile.listFiles()) {
            if(onto.getName().contains(".owl")) result.add(onto);
        }
        return result;
    }
    
    public File getCurrentOutputFolder(){
        File f = new File(new File(this.root + File.separator + this.output), this.currentFolder);
        if(!f.mkdir()) System.out.println(String.format("Unable to create output folder %s", this.currentFolder));
        return f;
    }
    
}